﻿CREATE PROCEDURE [dbo].[proc_discount_list]
(
    @diqu NVARCHAR(200),
    --@Title NVARCHAR(200),
    --@Content NVARCHAR(MAX),
	@StartIndex int,
	@EndIndex int,
	@flag int
	
)
AS
if @flag=0
BEGIN
	With List As(Select ROW_NUMBER() OVER (Order BY id Desc) AS Row,
		id,
		Title,
		Content,
		Createtime
		FROM discount_list	  
		where Diqu=@diqu
	)
	Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex Order By Row
END

if @flag=1
BEGIN
	With List As(Select ROW_NUMBER() OVER (Order BY id Desc) AS Row,
		id,
		Title,
		Content,
		Createtime
		FROM discount_list	  
	)
	Select *,(Select Count(0) From list) As RecordCount From list Where Row Between @StartIndex and @EndIndex Order By Row
END